package com.iwuke.dance;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.iwuke.dance.career.AddCareerActivity;
import com.iwuke.dance.wallet.WalletActivity;
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.header.ClassicsHeader;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);

        RefreshLayout refreshLayout = (RefreshLayout)findViewById(R.id.refreshLayout);
        refreshLayout.setRefreshHeader(new ClassicsHeader(this));
        refreshLayout.setRefreshFooter(new ClassicsFooter(this));
        refreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                refreshlayout.finishRefresh(2000/*,false*/);//传入false表示刷新失败
                Intent intent = new Intent(MainActivity.this, AddCareerActivity.class);
                startActivity(intent);
            }
        });
        refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(RefreshLayout refreshlayout) {
                refreshlayout.finishLoadMore(2000/*,false*/);//传入false表示加载失败
            }
        });

        TextView text_view = findViewById(R.id.text_view);
        text_view.post(new Runnable() {
            @Override
            public void run() {
                int height = text_view.getHeight(); // 获取实际高度（像素）
                int measuredHeight = text_view.getMeasuredHeight(); // 获取测量高度
                Log.d("++++++++++TextViewHeight", "实际高度：" + height + "，测量高度：" + measuredHeight);
                // 平移动画（X轴）
                ObjectAnimator transXAnim = ObjectAnimator.ofFloat(text_view, "translationY", 0f, height);
//                transXAnim.setDuration(height); // 设置持续时间(ms)
//                transXAnim.setStartDelay(500); // 设置延迟启动时间(ms)
//                ObjectAnimator transXAnim2 = ObjectAnimator.ofFloat(text_view, "translationY",200f, 0f);
//                transXAnim2.setDuration(1000); // 设置持续时间(ms)
//                transXAnim2.setStartDelay(500); // 设置延迟启动时间(ms)
//        transXAnim.setRepeatCount(ValueAnimator.INFINITE); // 设置无限循环
//        transXAnim.setRepeatMode(ValueAnimator.REVERSE); // 设置循环模式
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.playSequentially(transXAnim);
                animatorSet.start();

            }
        });
//        ObjectAnimator animator = ObjectAnimator.ofFloat(text_view, "alpha", 1f, 0f);
//        animator.setDuration(1000); // 设置持续时间(ms)
//        animator.setStartDelay(500); // 设置延迟启动时间(ms)
//        animator.setRepeatCount(ValueAnimator.INFINITE); // 设置无限循环
//        animator.setRepeatMode(ValueAnimator.REVERSE); // 设置循环模式
//        animator.setInterpolator(new AccelerateDecelerateInterpolator()); // 设置插值器


//        // 淡出动画
//        ObjectAnimator fadeOut = ObjectAnimator.ofFloat(text_view, "alpha", 1f, 0f);
//        fadeOut.setDuration(1500);
//
//        // 淡入动画
//        ObjectAnimator fadeIn = ObjectAnimator.ofFloat(text_view, "alpha", 0f, 1f);
//        fadeIn.setDuration(1500);
//
//        // 顺序执行动画
//        AnimatorSet animatorSet = new AnimatorSet();
//        animatorSet.playSequentially(fadeOut, fadeIn);
//
//        // 在淡出动画结束时更新文本
//        fadeOut.addListener(new AnimatorListenerAdapter() {
//            @Override
//            public void onAnimationEnd(Animator animation) {
//                super.onAnimationEnd(animation);
//
//            }
//        });
//
//        animatorSet.start();


    }
}